/*
*         (C) COPYRIGHT NBI Limited
*              ALL RIGHT RESERVED
*
* File        : fastflow/framework/allocator_info.h
* Authors     : dzhang
* Create Time : 2021/09/08 12:09:02
* Description :
*
*/

#ifndef __FASTFLOW_FRAMEWORK_ALLOCATOR_INFO_H___
#define __FASTFLOW_FRAMEWORK_ALLOCATOR_INFO_H___

#include "fastflow/framework/error_code.h"
//This file is part of the public C API
#ifdef __cplusplus
extern "C" {
#endif
typedef enum FASTFLOWAllocatorType {
  FASTFLOWDeviceAllocator = 0,
  FASTFLOWArenaAllocator = 1
} FASTFLOWAllocatorType;

/**
   memory types for allocator, exec provider specific types should be extended in each provider
*/
typedef enum FASTFLOWMemType {
  FASTFLOWMemTypeCPUInput = -2,                      // Any CPU memory used by non-CPU execution provider
  FASTFLOWMemTypeCPUOutput = -1,                     // CPU accessible memory outputted by non-CPU execution provider, i.e. CUDA_PINNED
  FASTFLOWMemTypeCPU = FASTFLOWMemTypeCPUOutput,  // temporary CPU accessible memory allocated by non-CPU execution provider, i.e. CUDA_PINNED
  FASTFLOWMemTypeDefault = 0,                        // the default allocator for execution provider
} FASTFLOWMemType;

DEFINE_RUNTIME_CLASS(FASTFLOWAllocatorInfo);

FASTFLOW_API_STATUS(FASTFLOWCreateAllocatorInfo, _In_ const char* name1, enum FASTFLOWAllocatorType type, int id1, enum FASTFLOWMemType mem_type1, _Out_ FASTFLOWAllocatorInfo** out);

/**
 * Test if two allocation info are equal
 * \return 0, equal. zero, not equal
 */
FASTFLOW_API(int, FASTFLOWCompareAllocatorInfo, _In_ const FASTFLOWAllocatorInfo* info1, _In_ const FASTFLOWAllocatorInfo* info2)
FASTFLOW_ALL_ARGS_NONNULL;
/**
 * Do not free the returned value
 */
FASTFLOW_API(const char*, FASTFLOWAllocatorInfoGetName, _In_ FASTFLOWAllocatorInfo* ptr);
FASTFLOW_API(int, FASTFLOWAllocatorInfoGetId, _In_ FASTFLOWAllocatorInfo* ptr);
FASTFLOW_API(FASTFLOWMemType, FASTFLOWAllocatorInfoGetMemType, _In_ FASTFLOWAllocatorInfo* ptr);
FASTFLOW_API(FASTFLOWAllocatorType, FASTFLOWAllocatorInfoGetType, _In_ FASTFLOWAllocatorInfo* ptr);
#ifdef __cplusplus
}
#endif

#endif // __FASTFLOW_FRAMEWORK_ALLOCATOR_INFO_H___
